<?php
/**
 * Created by PhpStorm.
 * User: qinzhi
 * Date: 2017/08/28
 * Time: 17:01
 */
class Service_VisitLog{

    /**
     * 添加访问日志
     * @param $uid
     * @param $type
     *          1 进入首页
     *          2 确认订单页
     *          3 不在配送范围
     *          4 生成订单
     *          5 订单页跳地址列表页
     *          6 添加地址
     *          7 跳转百度地图
     * @param string $date
     * @param string $remark
     * @return int
     */
    public static function add($uid,$type,$date='',$remark=''){
        $date = !empty($date) ? $date : date('Y-m-d');
        $ip = FRequest::getClientIP();
        $sql = "INSERT INTO `visit_log` (`uid`,`type`,`date`,`ip`,`remark`) 
                VALUES ({$uid},{$type},'{$date}','{$ip}','{$remark}') ON DUPLICATE KEY UPDATE `ip` = '{$ip}',`remark`='{$remark}'";
        return FDB::query($sql,'xhs_master');
    }
}